import type { IUser } from "@/models/user";

/**
 * 登录接口
 * @param {object} userInfo 用户信息
 * @param {string} userInfo.account 账户名称
 * @param {string} userInfo.password 账户密码
 */
export const userLogin = (userInfo: IUser) =>
  new Promise<{
    data: boolean;
    msg: string;
  }>((resolve, reject) => {
    // admin管理员默认账户密码
    const userAdminMockData = {
      account: "admin",
      password: "123456",
    };
    const { account = "", password = "" } = userInfo;
    if (
      userAdminMockData.account === account &&
      userAdminMockData.password === password
    ) {
      resolve({ data: true, msg: "登陆成功" });
    } else {
      reject({ data: false, msg: "账号密码不匹配" });
    }
  });
